/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jogl2.pkg0.project;

import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

/**
 *
 * @author Peter
 */
public class ControllerMouseClickMovement implements MouseMotionListener, MouseListener {

    
    private JOGL_PBERTRY_Feynmann_quadratic_mouse myPanel;
    private Point previousPoint = new Point(0,0);
    private int previousX = 0;
    
    
    public ControllerMouseClickMovement(JOGL_PBERTRY_Feynmann_quadratic_mouse myPanel) {
        this.myPanel = myPanel;
        
    }
    
    
    //-------- MouseMotionListerner methods
    // Remember that the MousePressed method has to initialize variable preivousPoing for this to work
    @Override
    public void mouseDragged(MouseEvent me) {
        
        
//        int tempx = me.getX();
//        int currentX = tempx;
//        currentX = currentX - previousX;
//        myPanel.updateMouseMovement(new Point(currentX,0));
//        previousX = tempx;
        
        Point tempPoint = me.getPoint();
        Point currentPoint = tempPoint;
        int curX = currentPoint.x - previousPoint.x;
        int curY = currentPoint.y - previousPoint.y;
        myPanel.updateMouseMovement(new Point(curX,curY));
        previousPoint = tempPoint;
        
    }

    @Override
    public void mouseMoved(MouseEvent me) {
    }
    
    //-------- Mouse listerner methods

    @Override
    public void mouseClicked(MouseEvent me) {
        

    }

    @Override
    public void mousePressed(MouseEvent me) {
        
//        previousX = me.getX();
        previousPoint = me.getPoint();
        
    }

    @Override
    public void mouseReleased(MouseEvent me) {
    }

    @Override
    public void mouseEntered(MouseEvent me) {
    }

    @Override
    public void mouseExited(MouseEvent me) {
    }
    
}
